package com.example.administrator.maizuofilm.main.fragment.activity;

import com.alibaba.fastjson.JSON;
import com.example.administrator.maizuofilm.bean.Active;
import com.example.administrator.maizuofilm.httputils.HttpUtils;

import org.greenrobot.eventbus.EventBus;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by Administrator on 2016/7/13.
 */
public class ActiveModel implements ActiveContract.Model {
    private OkHttpClient client = new OkHttpClient();
    @Override
    public void init() {
        Request request = new Request.Builder().url("http://mobileif.maizuo.com/ver4/city/12/film/0/cinema/4938/0?channelID=31&clientID=31&revision=4.6.5&agentID=xiaomi").build();
        client.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String json = response.body().string();
                Active active = JSON.parseObject(json, Active.class);
                EventBus.getDefault().post(active);
            }
        });

    }
}

